//
//  ViewController.m
//  ShareManagerDemo
//
//  Created by 曹敬贺 on 16/9/14.
//  Copyright © 2016年 北京无限点乐科技有限公司. All rights reserved.
//

#import "ViewController.h"
#import "ShareManager.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray * array = @[@"分享到QQ",@"分享到QZone",@"分享到Sina",@"分享到给WX朋友",@"分享到朋友圈"];
    for (int i = 0; i < 5; i++) {
        UIButton * but = [UIButton buttonWithType:UIButtonTypeCustom];
        but.frame = CGRectMake(100, 40 + 80*i, 150, 30);
        but.backgroundColor = [UIColor greenColor];
        but.tag = 1000 + i;
        [but setTitle:array[i] forState:UIControlStateNormal];
        [but addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:but];
    }
}
- (void)butClick1:(UIButton *)sender
{
    NSString * abURL =  @"http://tx-cdn.dianjoy.com/dev/upload/ad_url/201607/0_01e25f01b7cac332faf825df0fa2dd42_128_128.png";
    switch (sender.tag) {
        case 1000:
            [ShareManager shareTopicWithImageURL:abURL WithPlatform:SharePlatformQQ WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1001:
            [ShareManager shareTopicWithImageURL:abURL WithPlatform:SharePlatformQQZone WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1002:
            [ShareManager shareTopicWithImageURL:abURL WithPlatform:SharePlatformSina WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1003:
            [ShareManager shareTopicWithImageURL:abURL WithPlatform:SharePlatformWeChatFriend WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1004:
            [ShareManager shareTopicWithImageURL:abURL WithPlatform:SharePlatformWeChatFriendCircle WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        default:
            break;
    }
}
- (void)butClick:(UIButton *)sender
{
    switch (sender.tag) {
        case 1000:
            [ShareManager shareTopicWithTitle:@"里约奥运会" WithText:@"球体重心至球体中心距离不得大于6毫米，将去掉把手和链子的球体放在一个水平的、直径为12毫米的圆形口刃上，一球体必须保持平衡" WithImage:[UIImage imageNamed:@"shareImage"] WithDetailURL:@"https://www.baidu.com" WithPlatform:SharePlatformQQ WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1001:
            [ShareManager shareTopicWithTitle:@"里约奥运会" WithText:@"球体重心至球体中心距离不得大于6毫米，将去掉把手和链子的球体放在一个水平的、直径为12毫米的圆形口刃上，一球体必须保持平衡" WithImage:[UIImage imageNamed:@"shareImage"] WithDetailURL:@"https://www.baidu.com" WithPlatform:SharePlatformQQZone WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1002:
        {
            BOOL tt = [ShareManager shareTopicWithTitle:@"里约奥运会" WithText:@"球体重心至球体中心距离不得大于6毫米，将去掉把手和链子的球体放在一个水平的、直径为12毫米的圆形口刃上，一球体必须保持平衡" WithImage:[UIImage imageNamed:@"shareImage"] WithDetailURL:@"https://www.baidu.com" WithPlatform:SharePlatformSina WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            NSLog(@"结果:%d",tt);
        }
            break;
        case 1003:
            [ShareManager shareTopicWithTitle:@"里约奥运会" WithText:@"球体重心至球体中心距离不得大于6毫米，将去掉把手和链子的球体放在一个水平的、直径为12毫米的圆形口刃上，一球体必须保持平衡" WithImage:[UIImage imageNamed:@"shareImage"]  WithDetailURL:@"https://www.baidu.com" WithPlatform:SharePlatformWeChatFriend WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        case 1004:
            [ShareManager shareTopicWithTitle:@"里约奥运会" WithText:@"球体重心至球体中心距离不得大于6毫米，将去掉把手和链子的球体放在一个水平的、直径为12毫米的圆形口刃上，一球体必须保持平衡" WithImage:[UIImage imageNamed:@"shareImage"] WithDetailURL:@"https://www.baidu.com" WithPlatform:SharePlatformWeChatFriendCircle WithResult:^(BOOL result) {
                if (result) {
                    NSLog(@"分享成功");
                }else
                {
                    NSLog(@"分享失败");
                }
            }];
            break;
        default:
            break;
    }
}

@end
